home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DClap / DUtil.h < prev    next >
Text File  |  1996-07-05  |  4KB  |  167 lines

  1. // DUtil.h
  2. // d.g.gilbert
  3.  
  4. #ifndef _DUTIL_
  5. #define _DUTIL_
  6.  
  7. #include "Dvibrant.h"
  8. #include "DObject.h"
  9. #include "DWindow.h"
  10.  
  11. class DFile;
  12.  
  13. class DCursor : public DObject
  14. {    
  15. public:
  16.     void arrow() { Nlm_ArrowCursor(); }
  17.     void cross() { Nlm_CrossCursor(); }
  18.     void ibeam() { Nlm_IBeamCursor(); }
  19.     void plus()  { Nlm_PlusCursor(); }
  20.     void watch() { Nlm_WatchCursor(); }
  21. };
  22.  
  23.  
  24. class    DKeys    : public    DObject
  25. {
  26. public:
  27.     char    current();
  28.     Boolean    shift();
  29.     Boolean    control();
  30.     Boolean    option();
  31.     Boolean    command();
  32. };
  33.  
  34.  
  35.     // use this as a secondary parent for DView classes needing key handling
  36.     // vibrant makes this available...
  37. class DKeyCallback
  38. {
  39. public:
  40.     DKeyCallback();
  41.     virtual ~DKeyCallback();
  42.     virtual void SetKeyHandler(DKeyCallback* handler);
  43.   virtual void ProcessKey( char c) = 0;
  44. };
  45.  
  46.  
  47.  
  48. class    DMouse    : public    DObject
  49. {
  50. public:
  51.     void mouseat(Nlm_PoinT& pt) {
  52.         Nlm_MousePosition(&pt);
  53.         }
  54.     void mouseat(short& x, short& y) {
  55.         Nlm_PoinT pt;
  56.         Nlm_MousePosition(&pt);
  57.         x= pt.x; y= pt.y;
  58.         }
  59.     Boolean mousedown()     { return Nlm_MouseButton(); }
  60.     Boolean    doubleclick() { return Nlm_dblClick; }
  61. };
  62.  
  63.  
  64.  
  65. class    DPrefManager    : public DObject
  66. {
  67. public:
  68.     virtual char* GetAppPref(char* type, char* section, char* appname, char* defaultvalue = NULL,
  69.                                                         char* prefvalue= NULL, ulong maxsize = 256);
  70.     virtual char* GetPref(char* type, char* section, char* defaultvalue = NULL,
  71.                                                 char* prefvalue= NULL, ulong maxsize = 256);
  72.     virtual Boolean SetAppPref(char* prefvalue, char* type, char* section, char* appname);
  73.     virtual Boolean SetPref(char* prefvalue, char* type, char* section);
  74.     virtual Boolean RemovePrefSection(char* section, char* appname);
  75.     virtual char* GetAppPrefSection(char* section, ulong& sectlen, char* appname, char* defaultvalue = NULL,
  76.                                                         char* prefvalue= NULL, ulong maxsize = 4048);
  77.     virtual char* GetPrefSection(char* section, ulong& sectlen, char* defaultvalue = NULL,
  78.                                                 char* prefvalue= NULL, ulong maxsize = 4048);
  79.     virtual char** GetPrefFileLines(const char* prefFile, short& nlines); 
  80. };
  81.  
  82.  
  83.  
  84. class    DPrintManager    : public DObject
  85. {
  86. public:
  87.     Nlm_RecT fPageRect;
  88.     
  89.     DPrintManager();
  90.     DWindow* StartPrinting();
  91.     void DonePrinting(DWindow* savedWindow);
  92.     Boolean StartPage();
  93.     Boolean DonePage();
  94.     Boolean PrintRect(Nlm_RecT &rpt);
  95.     short    PageHeight(Boolean onScreen = TRUE);
  96.     short PageWidth(Boolean onScreen = TRUE);
  97. };
  98.  
  99.  
  100. class DString : public DObject
  101. {
  102.     char*    fStr;
  103. public:
  104.     DString() { fStr= NULL; }
  105.     DString(const char* s) { fStr= StrDup((char*) s); }
  106.     virtual ~DString() { if (fStr) MemFree(fStr); }
  107.     virtual const char* Get() { return fStr; }
  108.     virtual void Set(const char* s) { if (fStr) MemFree(fStr); fStr= StrDup((char*) s); }
  109. };
  110.  
  111.  
  112. class    DUtil    : public    DObject
  113. {
  114.     char    fVers[128];
  115. public:
  116.     DUtil() { 
  117.         Nlm_Version(fVers, 128); 
  118.         }
  119.         
  120.     virtual const char* version() const
  121.         { return (char*) fVers; 
  122.         }
  123.     long time()        
  124.         { return Nlm_ComputerTime(); 
  125.         }
  126.     void screensize( short& width, short& height) 
  127.         {
  128.         width = Nlm_screenRect.right - Nlm_screenRect.left;
  129.         height= Nlm_screenRect.bottom - Nlm_screenRect.top;
  130.         }
  131. };
  132.  
  133. class DErrorManager    : public DObject
  134. {
  135.     short    fErract;
  136.     short    fErrlog;
  137. public:
  138.     void TurnOff();
  139.     void TurnOn();
  140. };
  141.  
  142. class    DClapGlobals    : public    DObject
  143. {
  144. public:
  145.     DClapGlobals();
  146.     virtual ~DClapGlobals();
  147. };
  148.  
  149. extern    DCursor*    gCursor;
  150. extern    DMouse*        gMouse;
  151. extern    DKeys*        gKeys;
  152. extern    DUtil*        gUtil;
  153. extern    DPrintManager*    gPrintManager;
  154. extern    DErrorManager*    gErrorManager;
  155. extern    DPrefManager*        gPrefManager;
  156. extern  DKeyCallback*     gKeyHandlerObject;
  157.  
  158.  
  159. extern Nlm_FonT gTextFont, gItalicTextFont, gBoldTextFont, gUlineTextFont; 
  160. extern char        *    gTextFontName;
  161. extern short      gTextFontSize;
  162. extern short        gTextTabStops;
  163.  
  164.  
  165.  
  166. #endif
  167.